package com.cdx.spring.juc.printtrhead;

import java.util.concurrent.*;

/**
 * @author chedx
 * @data 2021/2/28 2:07 PM
 */
public class CallableTestMain {
    public static void main(String[] args) throws Exception{
        ExecutorService threadPool = Executors.newFixedThreadPool(2);
        MyCallable myCallable = new MyCallable();
        Future<Integer> future = threadPool.submit(myCallable);
        Integer integer = future.get();
        System.out.println(integer);
        FutureTask futureTask = new FutureTask(myCallable);
        Future<?> submit = threadPool.submit(futureTask);
        System.out.println(futureTask.get());
        threadPool.shutdown();
    }

    static class MyCallable implements Callable<Integer> {
        public Integer call() throws Exception {
            System.out.println("mycallabel");
            return 88;
        }
    }
}


